﻿<u:MainWindow x:Class="Ricciolo.PaperBoy.Themes.Classic.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:f="http://schemas.aspitalia.com/PaperBoyFeeds" 
    xmlns:u="http://schemas.aspitalia.com/PaperBoyUI" 
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" 
    xmlns:c="clr-namespace:Ricciolo.PaperBoy.Themes.Classic" 
    x:Name="mainWindow" 
    Height="700" Width="900"
    >

	<u:MainWindow.Resources>

		<Storyboard x:Key="fadeOut">
			<DoubleAnimation From="1" To="0" Storyboard.TargetProperty="Opacity" Duration="0:0:0.3" AccelerationRatio="0.9" />
		</Storyboard>
		<Storyboard x:Key="fadeIn">
			<DoubleAnimation From="0" To="1" Storyboard.TargetProperty="Opacity" Duration="0:0:0.3" AccelerationRatio="0.1" />
		</Storyboard>
		<Storyboard x:Key="fadeOutIn">
			<DoubleAnimation From="1" To="0" Duration="0:0:1" RepeatBehavior="Forever" AutoReverse="True" Storyboard.TargetProperty="Opacity" />
		</Storyboard>
		
	</u:MainWindow.Resources>


	<DockPanel LastChildFill="True">
		<Menu DockPanel.Dock="Top">
			<!-- menu -->
			<MenuItem Header="_Feeds">
				<MenuItem Command="f:FeedsCommands.SyncronizeAll" Header="{Binding Source={x:Static f:FeedsCommands.SyncronizeAll},Path=Text,Mode=OneTime}">
					<MenuItem.Icon>
						<Image Source="Resources/Refresh.ico" Width="16" Height="16" />
					</MenuItem.Icon>
				</MenuItem>
				<Separator />
				<MenuItem Command="f:FeedsCommands.MarkAsRead" Header="{Binding Source={x:Static f:FeedsCommands.MarkAsRead},Path=Text,Mode=OneTime}">
					<MenuItem.Icon>
						<Image Source="Resources/EmailEnvelope.ico" Width="16" Height="16" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Command="f:FeedsCommands.MarkAsUnread" Header="{Binding Source={x:Static f:FeedsCommands.MarkAsUnread},Path=Text,Mode=OneTime}">
					<MenuItem.Icon>
						<Image Source="Resources/SendLater.ico" Width="16" Height="16" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="_Open item">
					<MenuItem.Icon>
						<Image Source="Resources/Go.ico" Width="16" Height="16" />
					</MenuItem.Icon>
				  <MenuItem Header="{Binding Source={x:Static f:FeedsCommands.OpenItemInFeedTab},Path=Text,Mode=OneTime}" Command="f:FeedsCommands.OpenItemInFeedTab" CommandTarget="{Binding ElementName=mainWindow}" />
				  <MenuItem Header="{Binding Source={x:Static f:FeedsCommands.OpenItemInNewTab},Path=Text,Mode=OneTime}" Command="f:FeedsCommands.OpenItemInNewTab" CommandTarget="{Binding ElementName=mainWindow}" />
				  <MenuItem Header="{Binding Source={x:Static f:FeedsCommands.OpenItemInNewWindow},Path=Text,Mode=OneTime}" Command="f:FeedsCommands.OpenItemInNewWindow" CommandTarget="{Binding ElementName=mainWindow}" />
				</MenuItem>
				<MenuItem Command="f:FeedsCommands.GotoNextUnreadItem" Header="{Binding Source={x:Static f:FeedsCommands.GotoNextUnreadItem},Path=Text,Mode=OneTime}" InputGestureText="Space">
				</MenuItem>
				<Separator />
				<MenuItem Command="f:FeedsCommands.Preferences" Header="{Binding Source={x:Static f:FeedsCommands.Preferences},Path=Text,Mode=OneTime}" />
				<Separator />
				<MenuItem Command="ApplicationCommands.Close" Header="_Exit" />
			</MenuItem>
			<MenuItem Header="_Navigation">
				<MenuItem Command="NavigationCommands.BrowseBack" Header="{Binding Source={x:Static NavigationCommands.BrowseBack},Path=Text,Mode=OneTime}">
					<MenuItem.Icon>
						<Image Source="Resources/Back.ico" Width="16" Height="16" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Command="NavigationCommands.BrowseForward" Header="{Binding Source={x:Static NavigationCommands.BrowseForward},Path=Text,Mode=OneTime}">
					<MenuItem.Icon>
						<Image Source="Resources/Forward.ico" Width="16" Height="16" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Command="NavigationCommands.Refresh" Header="{Binding Source={x:Static NavigationCommands.Refresh},Path=Text,Mode=OneTime}">
					<MenuItem.Icon>
						<Image Source="Resources/Refresh.ico" Width="16" Height="16" />
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Command="NavigationCommands.BrowseStop" Header="{Binding Source={x:Static NavigationCommands.BrowseStop},Path=Text,Mode=OneTime}">
					<MenuItem.Icon>
						<Image Source="Resources/Stop.ico" Width="16" Height="16" />
					</MenuItem.Icon>
				</MenuItem>
			</MenuItem>
			<MenuItem Header="_Tools">
				<MenuItem Command="f:FeedsCommands.ThemesAndSkins" Header="{Binding Source={x:Static f:FeedsCommands.ThemesAndSkins},Path=Text,Mode=OneTime}" />
			</MenuItem>
			<MenuItem Header="_Help">
				<MenuItem Header="{Binding Source={x:Static f:FeedsCommands.About},Path=Text,Mode=OneTime}" Command="f:FeedsCommands.About" />
			</MenuItem>
		</Menu>
		<ToolBarTray DockPanel.Dock="Top">
			<ToolBar Band="1" Header="Feeds">
				<Button Command="f:FeedsCommands.SyncronizeAll" CommandTarget="{Binding ElementName=mainWindow}">
					<DockPanel>
						<Image Margin="0,0,2,0" DockPanel.Dock="Left" Source="Resources/Refresh.ico" Width="16" Height="16" />
						<AccessText Text="{Binding Source={x:Static f:FeedsCommands.SyncronizeAll},Path=Text,Mode=OneTime}" />
					</DockPanel>
				</Button>
				<Button Command="f:FeedsCommands.MarkAsRead" CommandTarget="{Binding ElementName=mainWindow}">
					<DockPanel>
						<Image Margin="0,0,2,0" DockPanel.Dock="Left" Source="Resources/EmailEnvelope.ico" Width="16" Height="16" />
						<AccessText Text="{Binding Source={x:Static f:FeedsCommands.MarkAsRead},Path=Text,Mode=OneTime}" />
					</DockPanel>
				</Button>

        <Menu Background="Transparent">
          <MenuItem>
            <MenuItem.Header>
              <DockPanel>
                <Image Margin="0,0,2,0" DockPanel.Dock="Left" Source="Resources/Go.ico" Width="16" Height="16" />
                <AccessText Text="_Open item" />
              </DockPanel>
            </MenuItem.Header>
            <MenuItem Header="{Binding Source={x:Static f:FeedsCommands.OpenItemInFeedTab},Path=Text,Mode=OneTime}" Command="f:FeedsCommands.OpenItemInFeedTab" CommandTarget="{Binding ElementName=mainWindow}" />
            <MenuItem Header="{Binding Source={x:Static f:FeedsCommands.OpenItemInNewTab},Path=Text,Mode=OneTime}" Command="f:FeedsCommands.OpenItemInNewTab" CommandTarget="{Binding ElementName=mainWindow}" />
            <MenuItem Header="{Binding Source={x:Static f:FeedsCommands.OpenItemInNewWindow},Path=Text,Mode=OneTime}" Command="f:FeedsCommands.OpenItemInNewWindow" CommandTarget="{Binding ElementName=mainWindow}" />
          </MenuItem>
        </Menu>
      </ToolBar>
			<ToolBar Band="2" Header="Navigation">
				<Button Command="NavigationCommands.BrowseBack" CommandTarget="{Binding ElementName=ieTab,Path=SelectedContent}">
					<DockPanel>
						<Image Margin="0,0,2,0" DockPanel.Dock="Left" Source="Resources/Back.ico" Width="16" Height="16" />
						<AccessText Text="{Binding Source={x:Static NavigationCommands.BrowseBack},Path=Text,Mode=OneTime}" />
					</DockPanel>
				</Button>
				<Button Command="NavigationCommands.BrowseForward" CommandTarget="{Binding ElementName=ieTab,Path=SelectedContent}">
					<DockPanel>
						<Image Margin="0,0,2,0" DockPanel.Dock="Left" Source="Resources/Forward.ico" Width="16" Height="16" />
						<AccessText Text="{Binding Source={x:Static NavigationCommands.BrowseForward},Path=Text,Mode=OneTime}" />
					</DockPanel>
				</Button>
				<Button Command="NavigationCommands.Refresh" CommandTarget="{Binding ElementName=ieTab,Path=SelectedContent}">
					<DockPanel>
						<Image Margin="0,0,2,0" DockPanel.Dock="Left" Source="Resources/Refresh.ico" Width="16" Height="16" />
						<AccessText Text="{Binding Source={x:Static NavigationCommands.Refresh},Path=Text,Mode=OneTime}" />
					</DockPanel>
				</Button>
				<Button Command="NavigationCommands.BrowseStop" CommandTarget="{Binding ElementName=ieTab,Path=SelectedContent}">
					<DockPanel>
						<Image Margin="0,0,2,0" DockPanel.Dock="Left" Source="Resources/Stop.ico" Width="16" Height="16" />
						<AccessText Text="{Binding Source={x:Static NavigationCommands.BrowseStop},Path=Text,Mode=OneTime}" />
					</DockPanel>
				</Button>
			</ToolBar>
		</ToolBarTray>
		<Grid x:Name="mainGrid">
			<Grid.Resources>

				<ResourceDictionary>

					<ResourceDictionary.MergedDictionaries>
						<ResourceDictionary Source="Styles.xaml" />
					</ResourceDictionary.MergedDictionaries>

					<c:FontWeightConverter x:Key="fontWeightConverter" />
					<u:DefaultStringConverter x:Key="defaultStringConverter" />
					<u:BitmapImageConverter x:Key="bitmapImageConverter" />
					<BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
					<u:NullToVisibilityConverter x:Key="nullToVisibilityConverter" />
					<u:NumberToVisibilityConverter Operator="NotEqual" x:Key="notEqualNumberToVisibilityConverter" />
					<u:StringFormatConverter x:Key="stringFormatConverter" />
					<u:NullToUnsetConverter x:Key="nullToUnsetConverter" />
					<u:FeedCollectionToListConverter x:Key="feedCollectionToListConverter" />
					<u:FeedItemToCommentsConverter x:Key="feedItemToCommentsConverter" />

          <!-- template for feed -->
          <HierarchicalDataTemplate DataType="{x:Type f:Feed}">
            <Grid>
              <Grid.ToolTip>
                <StackPanel>
                  <TextBlock>
                    <TextBlock>Unread items: </TextBlock>
                    <TextBlock Text="{Binding UnreadItemCount}" />
                  </TextBlock>
                  <TextBlock>
                    <TextBlock>Download status: </TextBlock>
                    <TextBlock Text="{Binding DownloadStatus}" />
                  </TextBlock>
                  <TextBlock>
                    <TextBlock>Last download: </TextBlock>
                    <TextBlock Text="{Binding LastDownloadTime}" />
                  </TextBlock>
                </StackPanel>
              </Grid.ToolTip>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="16" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
              </Grid.ColumnDefinitions>

				<Rectangle Grid.Column="0" Width="16" Height="16">
					<Rectangle.Fill>
						<Binding Path="FavIconBrush" Converter="{StaticResource nullToUnsetConverter}">
							<Binding.FallbackValue>
								<VisualBrush>
									<VisualBrush.Visual>
										<u:FeedIcon IsRefreshing="{Binding Path=IsDownloading}" />
									</VisualBrush.Visual>
								</VisualBrush>
							</Binding.FallbackValue>
						</Binding>
					</Rectangle.Fill>
				</Rectangle>
				<TextBlock Margin="2,2,0,0" Grid.Column="1" Text="{Binding Path=Name}" FontWeight="{Binding HasUnreadItems,Converter={StaticResource fontWeightConverter}}" />
							<TextBlock Grid.Column="2" VerticalAlignment="Center" Margin="2,2" Foreground="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" Visibility="{Binding Path=HasUnreadItems,Converter={StaticResource booleanToVisibilityConverter}}">
                <TextBlock.Resources>
                  <!-- style to change highlight -->
                  <Style TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                      <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                          <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor,{x:Type u:TreeViewItem}, 1},Mode=OneWay,Path=IsSelected}" Value="True" />
                          <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor,{x:Type u:TreeViewItem}, 1},Mode=OneWay,Path=IsSelectionActive}" Value="True" />
                        </MultiDataTrigger.Conditions>
                        <Setter Property="TextBlock.Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                      </MultiDataTrigger>
                    </Style.Triggers>
                  </Style>
                </TextBlock.Resources>
								<TextBlock>(</TextBlock><TextBlock Text="{Binding Path=UnreadItemCount}" /><TextBlock>)</TextBlock>
							</TextBlock>
						</Grid>

					</HierarchicalDataTemplate>

					<!-- template for feed folder-->
					<HierarchicalDataTemplate DataType="{x:Type f:FeedFolder}" ItemsSource="{Binding FoldersAndFeeds,Converter={StaticResource feedCollectionToListConverter}}">
						<Grid>
							<Grid.ToolTip>
								<StackPanel>
									<TextBlock>
										<TextBlock>Unread items: </TextBlock>
										<TextBlock Text="{Binding UnreadItemCount}" />
									</TextBlock>
									<TextBlock>
										<TextBlock>Folders and child feeds: </TextBlock>
										<TextBlock Text="{Binding FoldersAndFeeds.Count}" />
									</TextBlock>
								</StackPanel>
							</Grid.ToolTip>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="16" />
								<ColumnDefinition Width="Auto" />
								<ColumnDefinition Width="Auto" />
							</Grid.ColumnDefinitions>

							<Image Grid.Column="0" Source="Resources/Folder.png" Width="20" Height="20" />
							<TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="2,2" Text="{Binding Path=Name}" FontWeight="{Binding HasUnreadItems,Converter={StaticResource fontWeightConverter}}" />
							<TextBlock Grid.Column="2" VerticalAlignment="Center" Margin="2,2" Foreground="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" Visibility="{Binding Path=HasUnreadItems,Converter={StaticResource booleanToVisibilityConverter}}">
                <TextBlock.Resources>
                  <!-- style to change highlight -->
                  <Style TargetType="{x:Type TextBlock}">
                    <Style.Triggers>
                      <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                          <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor,{x:Type u:TreeViewItem}, 1},Mode=OneWay,Path=IsSelected}" Value="True" />
                          <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor,{x:Type u:TreeViewItem}, 1},Mode=OneWay,Path=IsSelectionActive}" Value="True" />
                        </MultiDataTrigger.Conditions>
                        <Setter Property="TextBlock.Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
                      </MultiDataTrigger>
                    </Style.Triggers>
                  </Style>
                </TextBlock.Resources>
                
								<TextBlock>(</TextBlock><TextBlock Text="{Binding Path=UnreadItemCount}" /><TextBlock>)</TextBlock>
							</TextBlock>
						</Grid>
					</HierarchicalDataTemplate>

					<DataTemplate x:Key="feedItemTemplate">
						<TextBlock Grid.Column="1" FontWeight="{Binding IsNotRead,Converter={StaticResource fontWeightConverter}}" Text="{Binding Title}">
							<TextBlock.ToolTip>
								<TextBlock Text="{Binding Title}" />
							</TextBlock.ToolTip>
						</TextBlock>

					</DataTemplate>

					<HierarchicalDataTemplate x:Key="feedItemChildsTemplate" ItemsSource="{Binding Converter={StaticResource feedItemToCommentsConverter}}">
					</HierarchicalDataTemplate>

					<Style x:Key="feedsListItemContainer" TargetType="{x:Type TreeViewItem}">
						<!-- expand automatically on first load-->
						<Setter Property="IsExpanded" Value="{Binding Mode=OneTime,Converter={StaticResource feedToSettingsConverter},ConverterParameter=IsExpanded}" />
					</Style>

				</ResourceDictionary>

			</Grid.Resources>

			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="*" />
				<ColumnDefinition Width="5" />
				<ColumnDefinition Width="2*" />
			</Grid.ColumnDefinitions>

			<!-- feeds treeview -->
			<u:TreeView Grid.Column="0" x:Name="feedsList" ItemsSource="{Binding Source={StaticResource feedSource},IsAsync=True}"
				TreeViewItem.Expanded="feedsList_Expanded" TreeViewItem.Collapsed="feedsList_Collapsed" ItemContainerStyle="{StaticResource feedsListItemContainer}">
				<u:TreeView.InputBindings>
					<KeyBinding Key="Space" Command="f:FeedsCommands.GotoNextUnreadItem" />
					<KeyBinding Key="Delete" Command="f:FeedsCommands.Delete" />
					<KeyBinding Modifiers="Alt" Key="Enter" Command="ApplicationCommands.Properties" />
				</u:TreeView.InputBindings>
				<u:TreeView.ContextMenu>
					<ContextMenu>
						<MenuItem Command="f:FeedsCommands.Download" Header="{Binding Source={x:Static f:FeedsCommands.Download},Path=Text,Mode=OneTime}" />
						<MenuItem Command="f:FeedsCommands.MarkAllAsRead" Header="{Binding Source={x:Static f:FeedsCommands.MarkAllAsRead},Path=Text,Mode=OneTime}" />
						<Separator/>
						<MenuItem Command="f:FeedsCommands.Delete" Header="{Binding Source={x:Static f:FeedsCommands.Delete},Path=Text,Mode=OneTime}" InputGestureText="Delete" />
						<Separator/>
						<MenuItem Command="ApplicationCommands.Properties" Header="_Properties" InputGestureText="Alt+Enter" />
					</ContextMenu>
				</u:TreeView.ContextMenu>
			</u:TreeView>

			<GridSplitter Grid.Column="1" 
			  HorizontalAlignment="Stretch" 
			  VerticalAlignment="Stretch"
			  Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" 
			  ShowsPreview="True"
			  ResizeDirection="Columns"
        />

			<Grid x:Name="feedGrid" Grid.Column="2" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">

				<Grid.RowDefinitions>
					<RowDefinition Height="*" />
					<RowDefinition Height="5" />
					<RowDefinition Height="2*" />
				</Grid.RowDefinitions>

				<Grid Grid.Row="0" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
					<!-- List view showing feed items -->
					<u:TreeListView x:Name="feedItems"
									 SnapsToDevicePixels="True"
									 ItemTemplate="{StaticResource feedItemChildsTemplate}" 
									 ItemsSource="{Binding ElementName=mainWindow,Path=CurrentFeed.Items}"
									 GridViewColumnHeader.Click="feedsItems_SortColumn">

						<u:TreeListView.InputBindings>
							<KeyBinding Key="Delete" Command="f:FeedsCommands.DeleteItem" />
							<KeyBinding Key="C" Modifiers="Control" Command="f:FeedsCommands.CopyLinkLocation" />
							<KeyBinding Key="Space" Command="f:FeedsCommands.GotoNextUnreadItem" />
						</u:TreeListView.InputBindings>
						<!-- context menu on items -->
						<u:TreeListView.ContextMenu>
							<ContextMenu>
								<MenuItem Command="f:FeedsCommands.OpenItemInFeedTab">
									<MenuItem.Header>
										<TextBlock FontWeight="Bold" Text="{Binding Source={x:Static f:FeedsCommands.OpenItemInFeedTab},Path=Text,Mode=OneTime}" />
									</MenuItem.Header>
								</MenuItem>
								<MenuItem Command="f:FeedsCommands.ViewComments" Header="_View comments..." />
								<Separator />
								<MenuItem Command="f:FeedsCommands.MarkAsRead" Header="Mark as _read" />
								<MenuItem Command="f:FeedsCommands.MarkAsUnread" Header="Mark as _unread" />
								<Separator />
								<MenuItem Command="f:FeedsCommands.CopyItemLocation" Header="Copy _feed location" />
								<MenuItem Command="f:FeedsCommands.CopyLinkLocation" Header="Copy _link location" InputGestureText="Ctrl+C" />
								<MenuItem Command="f:FeedsCommands.CopyCommentsLocation" Header="Copy _comments location" />
								<Separator />
								<MenuItem Command="f:FeedsCommands.DeleteItem" Header="_Delete" InputGestureText="Delete" />
							</ContextMenu>
						</u:TreeListView.ContextMenu>

						<u:TreeListView.Columns>
							<u:GridViewSortColumn SortPropertyName="Title" CellTemplate="{StaticResource feedItemTemplate}"
											Header="Title" Width="250" />
							<u:GridViewSortColumn SortPropertyName="PubDate" DisplayMemberBinding="{Binding PubDate}"
											Header="Date" Width="130" />
							<u:GridViewSortColumn SortPropertyName="Author" DisplayMemberBinding="{Binding Author}"
											Header="Author" Width="130" />
							<u:GridViewSortColumn SortPropertyName="CommentsCount" DisplayMemberBinding="{Binding CommentsCount}"
											Header="Comments" Width="70" />
						</u:TreeListView.Columns>

					</u:TreeListView>

					<!-- wait animated textblock -->
					<Viewbox Width="100" HorizontalAlignment="Center" VerticalAlignment="Center">
						<c:Loading Style="{StaticResource LoadingStyle}" />
					</Viewbox>
				</Grid>

				<GridSplitter Grid.Row="1" 
						HorizontalAlignment="Center" 
						VerticalAlignment="Stretch"
						Background="Black" 
						ShowsPreview="True"
						ResizeDirection="Rows"
						Width="100"/>

				<DockPanel Grid.Row="2">
					<StatusBar DockPanel.Dock="Bottom">
						<StatusBarItem Width="160" DockPanel.Dock="Right" Visibility="{Binding ElementName=ieTab,Path=SelectedContent.PercentComplete,FallbackValue=Collapsed,Mode=OneWay,Converter={StaticResource notEqualNumberToVisibilityConverter},ConverterParameter=100}">
							<ProgressBar Height="15" Width="150" Value="{Binding ElementName=ieTab,Path=SelectedContent.NavigationBytesRead,Mode=OneWay}" Minimum="0" Maximum="{Binding ElementName=ieTab,Path=SelectedContent.NavigationMaxBytes,Mode=OneWay}" />
						</StatusBarItem>

						<StatusBarItem>
							<TextBlock Text="{Binding ElementName=ieTab,Path=SelectedContent.StatusText,Mode=OneWay}" />
						</StatusBarItem>
					</StatusBar>

					<u:IETabControl x:Name="ieTab">

						<u:IETabControl.Resources>
							<Style TargetType="{x:Type u:IETabItem}">
								<Setter Property="HeaderTemplate">
									<Setter.Value>
										<DataTemplate>
											<Grid>
												<Grid.ColumnDefinitions>
													<ColumnDefinition />
													<ColumnDefinition />
												</Grid.ColumnDefinitions>
												<StackPanel Grid.Column="0" DataContext="{Binding RelativeSource={RelativeSource FindAncestor,{x:Type u:IETabItem}, 1}}" ToolTipService.InitialShowDelay="200" ToolTipService.ShowDuration="{x:Static s:Int32.MaxValue}">
													<StackPanel.ToolTip>
														<ToolTip>
															<Rectangle Width="160" Height="110" Fill="{Binding Frame.FrameScreenshot,Mode=OneWay}" />
														</ToolTip>
													</StackPanel.ToolTip>

													<StackPanel.ContextMenu>
														<ContextMenu>
															<MenuItem Command="{x:Static u:IETabItem.CloseTabCommand}" Header="{Binding Source={x:Static u:IETabItem.CloseTabCommand},Path=Text,Mode=OneTime}" />
															<MenuItem Command="{x:Static u:IETabItem.CloseOtherTabsCommand}" Header="{Binding Source={x:Static u:IETabItem.CloseOtherTabsCommand},Path=Text,Mode=OneTime}" />
															<Separator />
															<MenuItem Command="{x:Static u:IETabItem.RefreshTabCommand}" Header="{Binding Source={x:Static u:IETabItem.RefreshTabCommand},Path=Text,Mode=OneTime}" />
														</ContextMenu>
													</StackPanel.ContextMenu>
													<StackPanel.InputBindings>
														<MouseBinding MouseAction="MiddleClick" Command="{x:Static u:IETabItem.CloseTabCommand}" />
													</StackPanel.InputBindings>

													<TextBlock>
														<TextBlock Text="{Binding Path=Frame.PercentComplete,Mode=OneWay,Converter={StaticResource stringFormatConverter},ConverterParameter='\{0\}% - '}" Visibility="{Binding Path=Frame.PercentComplete,Mode=OneWay,Converter={StaticResource notEqualNumberToVisibilityConverter},ConverterParameter=100}" />
														<TextBlock MaxWidth="200" TextTrimming="WordEllipsis" Text="{Binding Path=Frame.DocumentTitle,RelativeSource={RelativeSource FindAncestor,{x:Type u:IETabItem}, 1}}" />
													</TextBlock>
												</StackPanel>

												<!-- Close button -->
												<Button Grid.Column="1" Width="16" Height="16" Margin="3,0,0,0" Command="{x:Static u:IETabItem.CloseTabCommand}" ToolTip="{Binding Source={x:Static u:IETabItem.CloseTabCommand},Path=Text,Mode=OneTime}">
													<Button.Template>
														<ControlTemplate>
															<Border BorderThickness="1" Background="Transparent" Name="bd" BorderBrush="{DynamicResource {x:Static SystemColors.InactiveBorderBrushKey}}" CornerRadius="4">
																<TextBlock Name="tb" Foreground="{DynamicResource {x:Static SystemColors.InactiveCaptionBrushKey}}" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" Text="X" />
															</Border>

															<ControlTemplate.Triggers>
																<Trigger Property="IsMouseOver" Value="True">
																	<Setter TargetName="tb" Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" />
																	<Setter TargetName="bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.InactiveBorderBrushKey}}" />
																	<Setter TargetName="bd" Property="BorderBrush" Value="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" />
																</Trigger>
															</ControlTemplate.Triggers>
														</ControlTemplate>
													</Button.Template>
												</Button>
											</Grid>
										</DataTemplate>
									</Setter.Value>
								</Setter>

							</Style>
						</u:IETabControl.Resources>

						<!-- first item. don't remove-->
						<TabItem>
							<TabItem.InputBindings>
								<KeyBinding Key="Space" Command="f:FeedsCommands.GotoNextUnreadItem" />
							</TabItem.InputBindings>

							<TabItem.Header>
								<TextBlock x:Name="title" MaxWidth="200" TextTrimming="WordEllipsis" Text="{Binding ElementName=feedItems,Path=SelectedValue.Title,FallbackValue='Start page'}" />
							</TabItem.Header>

							<u:FramePlus StatusText="{Binding ElementName=documentReader,Path=StatusText}">
								<u:FramePlus.Content>
									<Grid>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="*" />
										</Grid.ColumnDefinitions>
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition Height="*" />
										</Grid.RowDefinitions>

										<!-- feed details panel -->
										<Border Grid.Row="0" Padding="10" CornerRadius="5" BorderBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" BorderThickness="1" Visibility="{Binding ElementName=feedsList,Path=SelectedValue,Converter={StaticResource nullToVisibilityConverter}}">
											<Border.Background>
												<LinearGradientBrush EndPoint="0,8" StartPoint="0,0">
													<LinearGradientBrush.GradientStops>
														<GradientStop Offset="0" Color="{DynamicResource {x:Static SystemColors.WindowColorKey}}" />
														<GradientStop Offset="1" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
													</LinearGradientBrush.GradientStops>
												</LinearGradientBrush>
											</Border.Background>
											<Grid >
												<Grid.ColumnDefinitions>
													<ColumnDefinition Width="2*" />
													<ColumnDefinition Width="*" />
												</Grid.ColumnDefinitions>
												<Grid.RowDefinitions>
													<RowDefinition MaxHeight="30" />
													<RowDefinition MaxHeight="20" />
													<RowDefinition MaxHeight="20" />
													<RowDefinition MaxHeight="20" />
												</Grid.RowDefinitions>

												<TextBlock Grid.Column="0" Grid.Row="0" TextTrimming="WordEllipsis" VerticalAlignment="Center" Text="{Binding ElementName=feedItems,Path=SelectedValue.Feed.Title}" FontSize="14" FontWeight="Bold" />
												<TextBlock Grid.Column="0" Grid.Row="1" TextTrimming="WordEllipsis" VerticalAlignment="Center" Text="{Binding ElementName=feedItems,Path=SelectedValue.Title}" FontSize="14" FontStyle="Italic" />

												<Image Grid.Column="1" MaxWidth="150" MaxHeight="50" Grid.Row="0" Grid.RowSpan="2" Source="{Binding ElementName=feedItems,Path=SelectedValue.Feed.Image,Converter={StaticResource bitmapImageConverter}}"  VerticalAlignment="Center" Stretch="Uniform">
												</Image>

												<TextBlock Margin="0,5,0,0" Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" FontSize="12" FontStyle="Italic">
													<TextBlock>Author: </TextBlock>
													<TextBlock TextTrimming="CharacterEllipsis" Text="{Binding ElementName=feedItems,Path=SelectedValue.Author}" />
												</TextBlock>
												<TextBlock Margin="0,5,0,0" Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" FontSize="12" FontStyle="Italic">
													<TextBlock>Category: </TextBlock>
													<TextBlock TextTrimming="CharacterEllipsis" Text="{Binding ElementName=feedItems,Path=SelectedValue.Category}" />
												</TextBlock>

												<TextBlock Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" FontSize="11" FontStyle="Italic">
													<TextBlock>Comments: </TextBlock>
													<TextBlock Text="{Binding ElementName=feedItems,Path=SelectedValue.CommentsCount}" />
												</TextBlock>
												<TextBlock Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" FontSize="11" FontStyle="Italic">
													<TextBlock>Date: </TextBlock>
													<TextBlock Text="{Binding ElementName=feedItems,Path=SelectedValue.PubDate}" />
												</TextBlock>
											</Grid>
										</Border>

										<u:HtmlFlowDocumentReader Grid.Row="1" Html="{Binding ElementName=feedItems,Path=SelectedValue.Description}"
																   x:Name="documentReader" ViewingMode="Scroll">
											<u:HtmlFlowDocumentReader.Document>
												<FlowDocument>
													<BlockUIContainer>
														<Viewbox Stretch="Uniform" Width="150" Height="150">
															<u:Logo />
														</Viewbox>
													</BlockUIContainer>
													<Paragraph>
														<Span FontSize="18" FontWeight="Bold">Welcome to Ricciolo - PaperBoy!</Span><LineBreak />
														<Italic>version 0.3</Italic>
													</Paragraph>
													<Paragraph>
														<Bold>What's new?</Bold>
													</Paragraph>
													<List MarkerOffset="25" MarkerStyle="Box">
														<ListItem>
															<Paragraph>
																<Bold>Memory usage improvements</Bold>
																<LineBreak />
																Load feed items only when needed;<LineBreak />
															Unload feed items changing feed;<LineBreak />
																Load folder only when user expandes treeviewitem.
															</Paragraph>
														</ListItem>
														<ListItem>
															<Paragraph>
																<Bold>Improved hot key support</Bold>
																<LineBreak />
																Ctrl-R: Mark as read;<LineBreak />
																Ctrl-Shift-R: Mark all as read;<LineBreak />
																Ctrl-W or Middle button: Close tab;
															</Paragraph>
														</ListItem>
														<ListItem>
															<Paragraph>
																<Bold>Better navigation</Bold>
																<LineBreak />
																Unread items on feed/folder;<LineBreak />
																Mark all as read on folder;<LineBreak />
																State persisting (columns, opened folders, window size);
															</Paragraph>
														</ListItem>
														<ListItem>
															<Paragraph>
																<Bold>TreeView comments support</Bold>
																<LineBreak />
																Each feed item allow to view comments;<LineBreak />
															</Paragraph>
														</ListItem>
													</List>
													<Paragraph TextAlignment="Center">
														<Hyperlink NavigateUri="http://www.codeplex.com/paperboy">Visit the site</Hyperlink>
														<LineBreak />
														Copyright © 2006 Cristian Civera<LineBreak />
														<Hyperlink NavigateUri="mailto:cristian@aspitalia.com">cristian@aspitalia.com</Hyperlink>
													</Paragraph>
												</FlowDocument>
											</u:HtmlFlowDocumentReader.Document>

											<u:HtmlFlowDocumentReader.Triggers>
												<EventTrigger RoutedEvent="u:HtmlFlowDocumentReader.DocumentReset">
													<EventTrigger.Actions>
														<BeginStoryboard>
															<BeginStoryboard.Storyboard>
																<Storyboard Storyboard.TargetName="PART_viewer">
																	<StaticResource ResourceKey="fadeOut" />
																</Storyboard>
															</BeginStoryboard.Storyboard>
														</BeginStoryboard>
													</EventTrigger.Actions>
												</EventTrigger>
												<EventTrigger RoutedEvent="u:HtmlFlowDocumentReader.DocumentReady">
													<EventTrigger.Actions>
														<BeginStoryboard>
															<BeginStoryboard.Storyboard>
																<Storyboard Storyboard.TargetName="PART_viewer">
																	<StaticResource ResourceKey="fadeIn" />
																</Storyboard>
															</BeginStoryboard.Storyboard>
														</BeginStoryboard>
													</EventTrigger.Actions>
												</EventTrigger>
											</u:HtmlFlowDocumentReader.Triggers>
										</u:HtmlFlowDocumentReader>
									</Grid>	
								</u:FramePlus.Content>
							</u:FramePlus>
						</TabItem>

					</u:IETabControl>
					</DockPanel>
			</Grid>
		</Grid>
	</DockPanel>

</u:MainWindow>
